package com.sigmatrix.h5.enums.common;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;


public class NamedEnumEntitySerializer extends JsonSerializer<NamedEnumEntity<?>> {

    @Override
    public void serialize(NamedEnumEntity<?> enumEntity, JsonGenerator gen, SerializerProvider serializers)
            throws IOException, JsonProcessingException {

        gen.writeStartObject();
        gen.writeObjectField("id", enumEntity.getId());
        gen.writeStringField("name", enumEntity.getName());
        gen.writeEndObject();
    }
}
